class Solution(object):
    def rob(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums)==1:
            return nums[0]
        a = self.help(nums[1:])
        b = self.help(nums[:-1])
        return max(a,b)


    def help(self,nums):
        n = len(nums)
        if n == 0:
            return 0
        f = [0] *(n+1)
        f[0] = 0
        f[1] = nums[0]
        for i in range(2,n+1):
            # fang'f'zi房子从0开始  f[i]表示 第i-1个房子
            # f[i-1] 最后一个房子不偷 直接看前一个 前i-1栋
            f[i] = max(f[i-1],f[i-2]+nums[i-1])
        return f[-1]


a = [1]
s= Solution()
m = s.rob(a)
print(m)